package com.gitee.wsl.compose.mvi.component

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.gitee.wsl.compose.mvi.component.base.Interactable
import com.gitee.wsl.compose.mvi.component.base.Presentable

abstract class ListSlotProjector<T,Interactor, Presenter,Scope>(
    override val interactor: Interactor,
    override val presenter: Presenter
) : Projectable<Interactor, Presenter> where Interactor : Interactable, Presenter : Presentable<Presenter> {

    @Composable
    abstract fun body(combinedModifier: Modifier, interactor:Interactor, presenter:Presenter, slot: @Composable Scope.(Int, T) -> Unit)

    @Composable
    operator fun invoke(modifier: Modifier = Modifier,
                        content: @Composable Scope.(Int, T) -> Unit)
            = contextualize(modifier){ combinedModifier, interactor, presenter ->
        body(combinedModifier,interactor,presenter,content)
    }
}